# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Maintainer: David Runge <dvzrv@archlinux.org>
# Contributor: Giovanni Scafora <giovanni@archlinux.org>
# Contributor: kastor <kastor@fobos.org.ar>

_name=pupnp
pkgname=libupnp
pkgver=1.14.18
pkgrel=1
pkgdesc='Portable Open Source UPnP Development Kit'
arch=(loong64 x86_64)
url="https://pupnp.sourceforge.io/"
license=(BSD)
depends=(glibc)
makedepends=(cmake)
provides=(
  libixml.so
  libupnp.so
)
source=(https://github.com/$_name/$_name/archive/release-$pkgver/$_name-release-$pkgver.tar.gz)
sha512sums=('68973e0e5a8f9e64b2311246b7924b0837fd2c7ef30483d3d93ebfeee62bc2293760209d8a5213c0456ce5c37f9f32a6038c9e5d8b461670ba6073db8c2f1394')
b2sums=('ee95cafc10838817900f82b83d15cf5d925e36a4321c7000b963e9e986ca9165af55c4c90c6fdf5d9bfaf72695711337986d25498cb838d513470f20decf10cc')

build() {
  local cmake_options=(
    -B build
    -D CMAKE_BUILD_TYPE=None
    -D CMAKE_INSTALL_PREFIX=/usr
    -D UPNP_BUILD_STATIC=OFF
    -D blocking_tcp_connections=OFF
    -D reuseaddr=ON
    -S $_name-release-$pkgver
    -W no-dev
  )

  cmake "${cmake_options[@]}"
  cmake --build build --verbose
}

check() {
  ctest --test-dir build --output-on-failure
}

package() {
  DESTDIR="$pkgdir" cmake --install build
  install -vDm 644 $_name-release-$pkgver/COPYING -t "$pkgdir/usr/share/licenses/$pkgname"
  install -vDm 644 $_name-release-$pkgver/{ChangeLog,README.md} -t "$pkgdir/usr/share/doc/$pkgname"
}

# vim: ts=2 sw=2 et:
